﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;


namespace MShop.Core.Domain
{

    public interface IPayModel
    {
        object Get(string key);
    }

    public abstract class PayModelBase : IPayModel
    {
        public virtual object Get(string key)
        {
            System.Reflection.PropertyInfo[] propertyinfos = this.GetType().GetProperties();
            foreach (var prop in propertyinfos)
            {
                if (string.Equals(prop.Name, key, StringComparison.InvariantCultureIgnoreCase))
                {
                    if (prop.PropertyType == typeof(DateTime))
                    {
                        var obj = Convert.ToDateTime(prop.GetValue(this, null));
                        return obj.ToString("yyyy-MM-dd");
                    }
                    if (prop.PropertyType.IsGenericType)
                    {
                        if (prop.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
                        {
                            Type originalType = prop.PropertyType.GetGenericArguments()[0];
                            if (originalType == typeof(DateTime))
                            {
                                var obj2 = Convert.ToDateTime(prop.GetValue(this, null));
                                return obj2.ToString("yyyy-MM-dd");
                            }
                        }
                    }
                    return prop.GetValue(this, null);
                }
            }
            return string.Empty;
        }
    }

    [Serializable]
    public abstract class NormalPayModel : PayModelBase
    {

        [DisplayName("Logo地址")]
        public string Logo { get; set; }
        [Required(ErrorMessage = "商户密钥不能为空")]
        [DisplayName("商户密钥")]
        public string SecretKey { get; set; }
        [DisplayName("商户号")]
        [Required(ErrorMessage = "商户号不能为空")]
        public string Code { get; set; }
    }



    [Serializable]
    [DisplayName("货到付款")]
    public sealed class CodPayModel : PayModelBase
    {

    }



    [Serializable]
    [DisplayName("支付宝担保交易")]
    public sealed class AliPayasSurePayModel : NormalPayModel
    {
        [Required(ErrorMessage = "商户邮件不能为空")]
        [DisplayName("商户邮件")]
        public string Email { get; set; }

    }
    [Serializable]
    [DisplayName("支付宝即时到帐交易")]
    public sealed class AliPayDirectPayModel : NormalPayModel
    {
        [DisplayName("商户邮件")]
        public string Email { get; set; }
    }

    [Serializable]
    [DisplayName("快钱")]
    public sealed class _99BillPayModel : NormalPayModel
    {
        [DisplayName("合作伙伴")]
        public string Partner { get; set; }
    }
    [Serializable]
    [DisplayName("AllBuy")]
    public sealed class AllBuyPayModel : NormalPayModel
    {
    }
    [Serializable]
    [DisplayName("银行汇款")]
    public sealed class BankPayModel : PayModelBase
    {
    }
    [Serializable]
    [DisplayName("网银在线")]
    public class ChinaBankPayModel : NormalPayModel
    {
    }

    [Serializable]
    [DisplayName("云网支付")]
    public sealed class CnCardPayModel : NormalPayModel
    {
    }
    [Serializable]
    [DisplayName("中国在线支付网")]
    public sealed class ChinaOnlinePayPayModel : NormalPayModel
    {

    }
    [Serializable]
    [DisplayName("支付宝标准双接口(旧)")]
    public sealed class AliPayStandardPayModel : NormalPayModel
    {
        [DisplayName("商户邮件")]
        public string Email { get; set; }
    }



    [Serializable]
    [DisplayName("财付通即时到帐")]
    public sealed class TenPayModel : NormalPayModel
    {
        [DisplayName("商户邮件")]
        public string Email { get; set; }
    }
}